home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / clarion / disabl.exe / CONTA004.CLW < prev    next >
Text File  |  1995-01-05  |  25KB  |  716 lines

  1.                      MEMBER('CONTACTS.clw')       ! This is a MEMBER module
  2. BrowseByCompany PROCEDURE
  3.  
  4. LocalRequest         LONG,AUTO
  5. OriginalRequest      LONG,AUTO
  6. LocalResponse        LONG,AUTO
  7. WindowOpened         LONG
  8. WindowInitialized    LONG
  9. ForceRefresh         LONG,AUTO
  10. RecordFiltered       LONG
  11. Queue:Browse         QUEUE                        ! Browsing Queue
  12. Brw1::CON:Company      LIKE(CON:Company)          ! Queue Display field
  13. Brw1::CON:FirstName    LIKE(CON:FirstName)        ! Queue Display field
  14. Brw1::CON:LastName     LIKE(CON:LastName)         ! Queue Display field
  15. Brw1::CON:Address1     LIKE(CON:Address1)         ! Queue Display field
  16. Brw1::CON:Address2     LIKE(CON:Address2)         ! Queue Display field
  17. Brw1::CON:City         LIKE(CON:City)             ! Queue Display field
  18. Brw1::CON:State        LIKE(CON:State)            ! Queue Display field
  19. Brw1::CON:Zip          LIKE(CON:Zip)              ! Queue Display field
  20. Brw1::CON:Phone        LIKE(CON:Phone)            ! Queue Display field
  21. Brw1::CON:Fax          LIKE(CON:Fax)              ! Queue Display field
  22. Brw1::CON:JobTitle     LIKE(CON:JobTitle)         ! Queue Display field
  23. Brw1::CON:Interest     LIKE(CON:Interest)         ! Queue Display field
  24. Brw1::CON:TimeFrame    LIKE(CON:TimeFrame)        ! Queue Display field
  25. Brw1::CON:CurrentSoftware LIKE(CON:CurrentSoftware) ! Queue Display field
  26. Brw1::CON:Remarks      LIKE(CON:Remarks)          ! Queue Display field
  27. Brw1::Position         STRING(255)                ! Queue POSITION information
  28.                      END                          ! END (Browsing Queue)
  29. Brw1::RecordStatus   BYTE                         ! Flag for Range/Filter test
  30. Brw1::ItemsToFill    LONG                         ! Controls records retrieved
  31. Brw1::MaxItemsInList LONG                         ! Retrieved after window opened
  32. Brw1::LocatedPosition STRING(255)                 ! POSITION of located record
  33. Brw1::QueuePointer   LONG                         ! Queue position of located record
  34. Brw1::NextChoice     LONG                         ! Queue position of located record
  35. Brw1::CurrentScroll  BYTE                         ! Queue position of scroll thumb
  36. BrowseCoWindow       WINDOW('Browse by Company'),AT(24,26,247,129),FONT('Arial',10,,),SYSTEM,GRAY,MDI
  37.                        LIST,AT(5,5,235,100),MSG('Browsing Records'),USE(?List),IMM,HVSCROLL,FORMAT('80L~Company~@s25@80L~First Name~@s20@80L~Last Name~@s20@80L~Address 1~@s25@80L~A' &|
  38.    'ddress 2~@s25@80L~City~@s25@80L~State~@s2@80L~Zip~@s5@80L~Phone~@p(###) ###-####' &|
  39.    'p@80L~Fax~@p(###) ###-####p@80L~Job Title~@s25@80L~Interest~@s45@80L~Time Frame~' &|
  40.    '@s15@80L~Current Software~@s25@80L~Remarks~@s45@'),FROM(Queue:Browse)
  41.                        BUTTON('&Insert'),AT(5,110,45,12),USE(?Insert)
  42.                        BUTTON('&Change'),AT(50,110,45,12),USE(?Change),DEFAULT
  43.                        BUTTON('&Delete'),AT(95,110,45,12),USE(?Delete)
  44.                        BUTTON('&Select'),AT(145,110,40,12),USE(?Select)
  45.                        BUTTON('Close'),AT(200,110,40,12),USE(?Close)
  46.                      END
  47.   CODE
  48.   LocalRequest = GlobalRequest
  49.   OriginalRequest = GlobalRequest
  50.   LocalResponse = RequestCancelled
  51.   CLEAR(GlobalRequest)
  52.   CLEAR(GlobalResponse)
  53.   IF contacts::Used = 0
  54.     CheckOpen(contacts,1)
  55.   END
  56.   contacts::Used += 1
  57.   OPEN(BrowseCoWindow)
  58.   WindowOpened=True
  59.   !sets Global
  60.   BrowseByCompanyRef1 &= BrowseCoWindow
  61.   SET(CON:Key_Company)
  62.   ?List{Prop:Alrt,251} = MouseLeft2
  63.   IF LocalRequest = SelectRecord
  64.     ENABLE(?Select)
  65.     ?Select{Prop:Default} = True
  66.   ELSE
  67.     DISABLE(?Select)
  68.   END
  69.   ?List{Prop:Alrt,255} = InsertKey
  70.   ?List{Prop:Alrt,254} = DeleteKey
  71.   ?List{Prop:Alrt,253} = CtrlEnter
  72.   ACCEPT
  73.     CASE EVENT()
  74.     OF EVENT:CloseWindow
  75.       !Tells Global that window is closed
  76.       BrowseByCompanyOpen=0
  77.       DO RefreshWindow
  78.     OF EVENT:OpenWindow
  79.       IF NOT WindowInitialized
  80.         DO InitializeWindow
  81.       END
  82.       SELECT(?List)
  83.     OF EVENT:GainFocus
  84.       WindowInitialized = True
  85.       DO InitializeWindow
  86.     ELSE
  87.       CASE EVENT()
  88.       OF EVENT:Restore
  89.           IF BrowseByCompanyRef1{PROP:Iconize} = TRUE
  90.               BrowseByCompanyRef1{PROP:Iconize} = FALSE
  91.           END
  92.           BrowseByCompanyRef1{PROP:Active} = TRUE
  93.           POST(EVENT:Resume)
  94.       END
  95.     END
  96.     CASE FIELD()
  97.     OF ?List
  98.       CASE EVENT()
  99.       OF EVENT:Accepted
  100.         DO Brw1::FillBuffer
  101.         DO RefreshWindow
  102.       OF EVENT:NewSelection
  103.         DO Brw1::FillBuffer
  104.         DO RefreshWindow
  105.       OF EVENT:ScrollUp
  106.         DO Brw1::ScrollUp
  107.         DO RefreshWindow
  108.       OF EVENT:ScrollDown
  109.         DO Brw1::ScrollDown
  110.         DO RefreshWindow
  111.       OF EVENT:PageUp
  112.         DO Brw1::PageUp
  113.         DO RefreshWindow
  114.       OF EVENT:PageDown
  115.         DO Brw1::PageDown
  116.         DO RefreshWindow
  117.       OF EVENT:ScrollTop
  118.         DO Brw1::ScrollTop
  119.         DO RefreshWindow
  120.       OF EVENT:ScrollBottom
  121.         DO Brw1::ScrollBottom
  122.         DO RefreshWindow
  123.       OF EVENT:AlertKey
  124.         DO Brw1::AlertKey
  125.         DO RefreshWindow
  126.       END
  127.     OF ?Insert
  128.       CASE EVENT()
  129.       OF EVENT:Accepted
  130.         DO SyncWindow
  131.         DO Brw1::ButtonInsert
  132.         DO RefreshWindow
  133.       END
  134.     OF ?Change
  135.       CASE EVENT()
  136.       OF EVENT:Accepted
  137.         DO SyncWindow
  138.         DO Brw1::ButtonChange
  139.         DO RefreshWindow
  140.       END
  141.     OF ?Delete
  142.       CASE EVENT()
  143.       OF EVENT:Accepted
  144.         DO SyncWindow
  145.         DO Brw1::ButtonDelete
  146.         DO RefreshWindow
  147.       END
  148.     OF ?Select
  149.       CASE EVENT()
  150.       OF EVENT:Accepted
  151.         DO SyncWindow
  152.         LocalResponse = RequestCompleted
  153.         POST(Event:CloseWindow)
  154.         CYCLE
  155.         DO RefreshWindow
  156.       END
  157.     OF ?Close
  158.       CASE EVENT()
  159.       OF EVENT:Accepted
  160.         DO SyncWindow
  161.         LocalResponse = RequestCancelled
  162.         POST(Event:CloseWindow)
  163.         DO RefreshWindow
  164.       END
  165.     END
  166.   END
  167.   contacts::Used -= 1
  168.   IF contacts::Used = 0 THEN CLOSE(contacts).
  169.   IF WindowOpened
  170.     CLOSE(BrowseCoWindow)
  171.   END
  172.   IF LocalResponse
  173.     GlobalResponse = LocalResponse
  174.   ELSE
  175.     GlobalResponse = RequestCancelled
  176.   END
  177.   RETURN
  178. !---------------------------------------------------------------------------
  179. InitializeWindow ROUTINE
  180.   DO Brw1::OpenWindow
  181.   ForceRefresh = True
  182.   DO RefreshWindow
  183. !---------------------------------------------------------------------------
  184. RefreshWindow ROUTINE
  185.   IF ForceRefresh
  186.     GET(Queue:Browse,CHOICE(?List))
  187.     REGET(CON:Key_Company,Brw1::Position)
  188.     DO Brw1::ValidateRecord
  189.     IF Brw1::RecordStatus <> Record:OK
  190.       FREE(Queue:Browse)
  191.       SET(CON:Key_Company)
  192.       DO Brw1::RefreshPage
  193.     ELSE
  194.       DO Brw1::LocateRecord
  195.     END
  196.   ELSE
  197.     DO Brw1::ValidateRecord
  198.     IF Brw1::RecordStatus <> Record:OK
  199.       FREE(Queue:Browse)
  200.       SET(CON:Key_Company)
  201.       DO Brw1::RefreshPage
  202.     END
  203.   END
  204.   ?List{Prop:VScrollPos} = Brw1::CurrentScroll
  205.   DISPLAY()
  206.   ForceRefresh = False
  207. !---------------------------------------------------------------------------
  208. SyncWindow ROUTINE
  209.   IF RECORDS(Queue:Browse)
  210.     GET(Queue:Browse,CHOICE(?List))
  211.     REGET(CON:Key_Company,Brw1::Position)
  212.   END
  213. !---------------------------------------------------------------------------
  214. Brw1::OpenWindow ROUTINE
  215.   IF LocalRequest = SelectRecord
  216.     SET(CON:Key_Company,CON:Key_Company)
  217.     DO Brw1::LocateRecord
  218.   ELSE
  219.     SET(CON:Key_Company)
  220.     DO Brw1::RefreshPage
  221.     SELECT(?List,1)
  222.   END
  223.   DO Brw1::FillBuffer
  224. !----------------------------------------------------------------------
  225. Brw1::FillBuffer ROUTINE
  226.   GET(Queue:Browse,CHOICE(?List))
  227.   CON:Company = Brw1::CON:Company
  228.   CON:FirstName = Brw1::CON:FirstName
  229.   CON:LastName = Brw1::CON:LastName
  230.   CON:Address1 = Brw1::CON:Address1
  231.   CON:Address2 = Brw1::CON:Address2
  232.   CON:City = Brw1::CON:City
  233.   CON:State = Brw1::CON:State
  234.   CON:Zip = Brw1::CON:Zip
  235.   CON:Phone = Brw1::CON:Phone
  236.   CON:Fax = Brw1::CON:Fax
  237.   CON:JobTitle = Brw1::CON:JobTitle
  238.   CON:Interest = Brw1::CON:Interest
  239.   CON:TimeFrame = Brw1::CON:TimeFrame
  240.   CON:CurrentSoftware = Brw1::CON:CurrentSoftware
  241.   CON:Remarks = Brw1::CON:Remarks
  242. !----------------------------------------------------------------------
  243. Brw1::FillQueue ROUTINE
  244.   Brw1::CON:Company = CON:Company
  245.   Brw1::CON:FirstName = CON:FirstName
  246.   Brw1::CON:LastName = CON:LastName
  247.   Brw1::CON:Address1 = CON:Address1
  248.   Brw1::CON:Address2 = CON:Address2
  249.   Brw1::CON:City = CON:City
  250.   Brw1::CON:State = CON:State
  251.   Brw1::CON:Zip = CON:Zip
  252.   Brw1::CON:Phone = CON:Phone
  253.   Brw1::CON:Fax = CON:Fax
  254.   Brw1::CON:JobTitle = CON:JobTitle
  255.   Brw1::CON:Interest = CON:Interest
  256.   Brw1::CON:TimeFrame = CON:TimeFrame
  257.   Brw1::CON:CurrentSoftware = CON:CurrentSoftware
  258.   Brw1::CON:Remarks = CON:Remarks
  259.   Brw1::Position = POSITION(CON:Key_Company)
  260. !----------------------------------------------------------------------
  261. Brw1::ScrollUp ROUTINE
  262.   IF CHOICE(?List)>1
  263.     SELECT(?List, CHOICE(?List)-1)
  264.     POST(Event:NewSelection,?List)
  265.   ELSE
  266.     GET(Queue:Browse,1)                           ! Get the first queue item
  267.     RESET(CON:Key_Company,Brw1::Position)         ! Reset for sequential processing
  268.     NOMEMO(contacts)
  269.     PREVIOUS(contacts)                            ! Retrieve record, reverse access
  270.     Brw1::ItemsToFill = 1                         ! Load a single item
  271.     DO Brw1::FillBackward                         ! Fill with previous read(s)
  272.     IF Brw1::ItemsToFill                          ! If Load failed
  273.       Brw1::CurrentScroll = 0                     ! Move Thumb to top
  274.     ELSE
  275.       Brw1::CurrentScroll = 50                    ! Move Thumb to center
  276.     END
  277.   END
  278. !----------------------------------------------------------------------
  279. Brw1::ScrollDown ROUTINE
  280.   IF CHOICE(?List)<RECORDS(Queue:Browse)
  281.     SELECT(?List, CHOICE(?List)+1)
  282.     POST(Event:NewSelection,?List)
  283.   ELSE
  284.     GET(Queue:Browse,RECORDS(Queue:Browse))       ! Get the last queue item
  285.     RESET(CON:Key_Company,Brw1::Position)         ! Reset for sequential processing
  286.     NOMEMO(contacts)
  287.     NEXT(contacts)                                ! Retrieve record, forward access
  288.     Brw1::ItemsToFill = 1                         ! load a single item
  289.     DO Brw1::FillForward                          ! Fill with next read(s)
  290.     IF Brw1::ItemsToFill                          ! If Load failed
  291.       Brw1::CurrentScroll = 100                   ! Move Thumb to top
  292.     ELSE
  293.       Brw1::CurrentScroll = 50                    ! Move Thumb to center
  294.     END
  295.   END
  296. !----------------------------------------------------------------------
  297. Brw1::PageUp ROUTINE
  298.   GET(Queue:Browse,1)                             ! Get the first queue item
  299.   RESET(CON:Key_Company,Brw1::Position)           ! Reset for sequential processing
  300.   NOMEMO(contacts)
  301.   PREVIOUS(contacts)                              ! Retrieve record, reverse access
  302.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  303.   DO Brw1::FillBackward                           ! Fill with previous read(s)
  304.   IF Brw1::ItemsToFill
  305.     Brw1::NextChoice = CHOICE(?List)-Brw1::ItemsToFill
  306.     IF Brw1::NextChoice < 1
  307.       Brw1::NextChoice = 1
  308.     END
  309.     SELECT(?List, Brw1::NextChoice)
  310.     Brw1::CurrentScroll = 0                       ! Move Thumb to top
  311.   ELSE
  312.     Brw1::CurrentScroll = 50                      ! Move Thumb to center
  313.   END
  314. !----------------------------------------------------------------------
  315. Brw1::PageDown ROUTINE
  316.   GET(Queue:Browse,RECORDS(Queue:Browse))         ! Get the last queue item
  317.   RESET(CON:Key_Company,Brw1::Position)           ! Reset for sequential processing
  318.   NOMEMO(contacts)
  319.   NEXT(contacts)                                  ! Retrieve record, forward access
  320.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  321.   DO Brw1::FillForward                            ! Fill with next read(s)
  322.   IF Brw1::ItemsToFill
  323.     Brw1::NextChoice = CHOICE(?List)+Brw1::ItemsToFill
  324.     IF Brw1::NextChoice > RECORDS(Queue:Browse)
  325.       Brw1::NextChoice = RECORDS(Queue:Browse)
  326.     END
  327.     SELECT(?List, Brw1::NextChoice)
  328.     Brw1::CurrentScroll = 100                     ! Move Thumb to top
  329.   ELSE
  330.     Brw1::CurrentScroll = 50                      ! Move Thumb to center
  331.   END
  332. !----------------------------------------------------------------------
  333. Brw1::ScrollTop ROUTINE
  334.   FREE(Queue:Browse)                              ! Free the browse queue
  335.   SET(CON:Key_Company)
  336.   DO Brw1::RefreshPage
  337.   SELECT(?List,1)                                 ! Select first list item
  338.   Brw1::CurrentScroll = 0
  339. !----------------------------------------------------------------------
  340. Brw1::ScrollBottom ROUTINE
  341.   SETCURSOR(Cursor:Wait)
  342.   FREE(Queue:Browse)                              ! Free the browse queue
  343.   SET(CON:Key_Company)
  344.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  345.   DO Brw1::FillBackward                           ! Fill with previous read(s)
  346.   SELECT(?List, RECORDS(Queue:Browse))            ! Select last list item
  347.   IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  348.     Brw1::CurrentScroll = 100
  349.   ELSE
  350.     Brw1::CurrentScroll = 0
  351.   END
  352.   SETCURSOR()
  353. !----------------------------------------------------------------------
  354. Brw1::AlertKey ROUTINE
  355.   CASE KEYCODE()                                  ! What keycode was hit
  356.   OF MouseLeft2
  357.     IF LocalRequest = SelectRecord
  358.       POST(Event:Accepted,?Select)
  359.       EXIT
  360.     END
  361.     POST(Event:Accepted,?Change)
  362.     EXIT
  363.   OF InsertKey
  364.     POST(Event:Accepted,?Insert)
  365.   OF DeleteKey
  366.     POST(Event:Accepted,?Delete)
  367.   OF CtrlEnter
  368.     POST(Event:Accepted,?Change)
  369.   ELSE                                            ! ELSE (What keycode was hit)
  370.     IF CHR(KEYCHAR())
  371.       SET(CON:Key_Company)
  372.       CON:Company = CHR(KEYCHAR())
  373.       DO Brw1::LocateRecord                       ! Find the record
  374.     END
  375.   END                                             ! END (What keycode was hit)
  376. !----------------------------------------------------------------------
  377. Brw1::ValidateRecord ROUTINE
  378.   Brw1::RecordStatus = Record:OutOfRange
  379.   IF ERRORCODE() THEN EXIT.
  380.   Brw1::RecordStatus = Record:OK
  381.   EXIT
  382. !----------------------------------------------------------------------
  383. Brw1::FillForward ROUTINE
  384.   LOOP WHILE Brw1::ItemsToFill
  385.     NEXT(contacts)
  386.     DO Brw1::ValidateRecord
  387.     EXECUTE(Brw1::RecordStatus)
  388.       BEGIN
  389.         SET(CON:Key_Company)
  390.         BREAK
  391.       END
  392.       CYCLE
  393.     END
  394.     IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  395.       GET(Queue:Browse,1)
  396.       DELETE(Queue:Browse)
  397.     END
  398.     Brw1::ItemsToFill -= 1
  399.     DO Brw1::FillQueue
  400.     ADD(Queue:Browse)
  401.   END
  402.   EXIT
  403. !----------------------------------------------------------------------
  404. Brw1::FillBackward ROUTINE
  405.   LOOP WHILE Brw1::ItemsToFill
  406.     PREVIOUS(contacts)
  407.     DO Brw1::ValidateRecord
  408.     EXECUTE(Brw1::RecordStatus)
  409.       BEGIN
  410.         SET(CON:Key_Company)
  411.         BREAK
  412.       END
  413.       CYCLE
  414.     END
  415.     IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  416.       GET(Queue:Browse,RECORDS(Queue:Browse))
  417.       DELETE(Queue:Browse)
  418.     END
  419.     Brw1::ItemsToFill -= 1
  420.     DO Brw1::FillQueue
  421.     ADD(Queue:Browse,1)
  422.   END
  423.   EXIT
  424. !----------------------------------------------------------------------
  425. Brw1::LocateRecord ROUTINE
  426.   SETCURSOR(Cursor:Wait)
  427.   FREE(Queue:Browse)
  428.   SET(CON:Key_Company,CON:Key_Company)
  429.   Brw1::LocatedPosition = ''
  430.   LOOP
  431.     NEXT(contacts)
  432.     DO Brw1::ValidateRecord                           
  433.     EXECUTE(Brw1::RecordStatus)
  434.       BREAK
  435.       CYCLE
  436.     END
  437.     Brw1::LocatedPosition = POSITION(CON:Key_Company)
  438.     RESET(CON:Key_Company,Brw1::LocatedPosition)
  439.     BREAK
  440.   END
  441.   Brw1::ItemsToFill = ?List{Prop:Items}
  442.   Brw1::CurrentScroll = 50
  443.   DO Brw1::FillForward
  444.   IF Brw1::ItemsToFill
  445.     Brw1::CurrentScroll = 100
  446.     IF ~RECORDS(Queue:Browse)
  447.       SET(CON:Key_Company)
  448.     ELSE
  449.       GET(Queue:Browse,1)
  450.       RESET(CON:Key_Company,Brw1::Position)
  451.       PREVIOUS(contacts)
  452.     END
  453.     DO Brw1::FillBackward
  454.     IF Brw1::ItemsToFill
  455.       Brw1::CurrentScroll = 0
  456.     END
  457.   END
  458.   IF ~RECORDS(Queue:Browse)
  459.     CLEAR(CON:Record)
  460.     CLEAR(CON:Remarks)
  461.     SET(CON:Key_Company)
  462.     ?Change{Prop:Disable} = 1
  463.     ?Delete{Prop:Disable} = 1
  464.   ELSE
  465.     IF Brw1::LocatedPosition
  466.       Brw1::QueuePointer = 1
  467.       LOOP
  468.         GET(Queue:Browse,Brw1::QueuePointer)
  469.         IF ERRORCODE() THEN BREAK.
  470.         IF Brw1::Position = Brw1::LocatedPosition THEN BREAK.
  471.         Brw1::QueuePointer += 1
  472.       END
  473.     ELSE
  474.       Brw1::QueuePointer = RECORDS(Queue:Browse)
  475.     END
  476.     SELECT(?List,Brw1::QueuePointer)
  477.     DO Brw1::FillBuffer
  478.     REGET(CON:Key_Company,Brw1::Position)
  479.     ?Change{Prop:Disable} = 0
  480.     ?Delete{Prop:Disable} = 0
  481.   END
  482.   SETCURSOR()
  483. !----------------------------------------------------------------------
  484. Brw1::RefreshPage ROUTINE
  485.   SETCURSOR(Cursor:Wait)
  486.   IF RECORDS(Queue:Browse)
  487.     GET(Queue:Browse,1)
  488.     RESET(CON:Key_Company,Brw1::Position)
  489.     FREE(Queue:Browse)
  490.   END
  491.   Brw1::ItemsToFill = ?List{Prop:Items}
  492.   Brw1::CurrentScroll = 50
  493.   DO Brw1::FillForward
  494.   IF Brw1::ItemsToFill
  495.     GET(Queue:Browse,1)
  496.     RESET(CON:Key_Company,Brw1::Position)
  497.     PREVIOUS(contacts)
  498.     Brw1::CurrentScroll = 100
  499.     DO Brw1::FillBackward
  500.     IF Brw1::ItemsToFill
  501.       Brw1::CurrentScroll = 0
  502.     END
  503.   END
  504.   IF ~RECORDS(Queue:Browse)
  505.     CLEAR(CON:Record)
  506.     CLEAR(CON:Remarks)
  507.     SET(CON:Key_Company)
  508.     ?Change{Prop:Disable} = 1
  509.     ?Delete{Prop:Disable} = 1
  510.   ELSE
  511.     DO Brw1::FillBuffer
  512.     REGET(CON:Key_Company,Brw1::Position)
  513.     ?Change{Prop:Disable} = 0
  514.     ?Delete{Prop:Disable} = 0
  515.   END
  516.   SETCURSOR()
  517. !----------------------------------------------------------------
  518. Brw1::ButtonInsert ROUTINE
  519.   GET(contacts,0)
  520.   CLEAR(CON:Record,0)
  521.   CLEAR(CON:Remarks)
  522.   SET(CON:Key_Company)
  523.   GlobalRequest = InsertRecord
  524.   UpdateProc
  525.   IF GlobalResponse = RequestCompleted
  526.     DO Brw1::ValidateRecord
  527.     IF Brw1::RecordStatus = Record:OK
  528.       DO Brw1::LocateRecord
  529.     END
  530.   END
  531.   ForceRefresh = True
  532.   LocalRequest = OriginalRequest
  533. !----------------------------------------------------------------
  534. Brw1::ButtonChange ROUTINE
  535.   GlobalRequest = ChangeRecord
  536.   UpdateProc
  537.   IF GlobalResponse = RequestCompleted
  538.     DO Brw1::ValidateRecord
  539.     IF Brw1::RecordStatus = Record:OK
  540.       DO Brw1::LocateRecord
  541.     ELSE
  542.       SELECT(?List,CHOICE(?List))
  543.     END
  544.   END
  545.   ForceRefresh = True
  546.   LocalRequest = OriginalRequest
  547. !----------------------------------------------------------------
  548. Brw1::ButtonDelete ROUTINE
  549.   GlobalRequest = DeleteRecord
  550.   UpdateProc
  551.   IF GlobalResponse = RequestCompleted
  552.     DELETE(Queue:Browse)
  553.     DO Brw1::RefreshPage
  554.   END
  555.   SELECT(?List,CHOICE(?List))
  556.   ForceRefresh = True
  557.   LocalRequest = OriginalRequest
  558.  
  559. ReportByCompany PROCEDURE
  560. RejectRecord         LONG,AUTO
  561. LocalRequest         LONG,AUTO
  562. LocalResponse        LONG,AUTO
  563. WindowOpened         LONG,AUTO
  564. RecordsToProcess     LONG,AUTO
  565. RecordsProcessed     LONG,AUTO
  566. RecordsPerCycle      LONG,AUTO
  567. RecordsThisCycle     LONG,AUTO
  568. PercentProgress      DECIMAL(4,1)
  569. RecordStatus         BYTE,AUTO
  570. report               REPORT,AT(1000,2000,6000,7000),PRE(RPT),FONT('Arial',10,,),THOUS
  571.                        HEADER,AT(1000,1000,6000,1000)
  572.                          STRING('Contact Detail Sheet'),AT(1250,417,,),FONT('Arial',28,,FONT:bold+FONT:italic+FONT:underline),USE(?String16)
  573.                        END
  574. detail                 DETAIL
  575.                          STRING(@s25),AT(0,0,,),USE(CON:Company)
  576.                          STRING(@s20),AT(0,200,,),USE(CON:FirstName)
  577.                          STRING(@s20),AT(0,400,,),USE(CON:LastName)
  578.                          STRING(@s25),AT(0,600,,),USE(CON:Address1)
  579.                          STRING(@s25),AT(0,800,,),USE(CON:Address2)
  580.                          STRING(@s25),AT(0,1000,,),USE(CON:City)
  581.                          STRING(@s2),AT(0,1200,,),USE(CON:State)
  582.                          STRING(@s5),AT(0,1400,,),USE(CON:Zip)
  583.                          STRING(@p(###) ###-####p),AT(0,1600,,),USE(CON:Phone)
  584.                          STRING(@p(###) ###-####p),AT(0,1800,,),USE(CON:Fax)
  585.                          STRING(@s25),AT(0,2000,,),USE(CON:JobTitle)
  586.                          STRING(@s45),AT(0,2200,,),USE(CON:Interest)
  587.                          STRING(@s15),AT(0,2400,,),USE(CON:TimeFrame)
  588.                          STRING(@s25),AT(0,2600,,),USE(CON:CurrentSoftware)
  589.                          STRING(@s45),AT(0,2800,,),USE(CON:Remarks)
  590.                        END
  591.                        FOOTER,AT(1000,9000,6000,1000)
  592.                        END
  593.                      END
  594. ProgressWindow       WINDOW('Progress...'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE
  595.                        STRING(''),AT(0,3,141,10),USE(?Progress:UserString),CENTER
  596.                        BOX,AT(15,15,111,12),COLOR(00H),FILL(0FFFFFFH)
  597.                        BOX,AT(21,18,100,6),COLOR(00H),FILL(0C0C0C0H)
  598.                        BOX,AT(21,18,100,6),USE(?Progress:Thermometer),FILL(0FFH)
  599.                        STRING(''),AT(0,30,141,10),USE(?Progress:PctText),CENTER
  600.                        BUTTON('Cancel'),AT(45,42,50,15),USE(?Progress:Cancel)
  601.                      END
  602.   CODE
  603.   LocalRequest = GlobalRequest
  604.   LocalResponse = RequestCancelled
  605.   CLEAR(GlobalRequest)
  606.   CLEAR(GlobalResponse)
  607.   IF contacts::Used = 0
  608.     CheckOpen(contacts,1)
  609.   END
  610.   contacts::Used += 1
  611.   OPEN(ProgressWindow)
  612.   RecordsToProcess = RECORDS(contacts)
  613.   RecordsPerCycle = 25
  614.   RecordsToProcess = RECORDS(contacts)
  615.   RecordsPerCycle = 25
  616.   RecordsProcessed = 0
  617.   PercentProgress = 0
  618.   ?Progress:Thermometer{Prop:Width} = 0
  619.   ?Progress:PctText{Prop:Text} = '0.0% Completed'
  620.     ProgressWindow{Prop:Text} = 'Printing Report'
  621.   ?Progress:UserString{Prop:Text}=''
  622.   ACCEPT
  623.     CASE EVENT()
  624.     OF Event:OpenWindow
  625.       SET(CON:Key_Company)
  626.       LOOP
  627.         DO GetNextcontacts
  628.         DO ValidateRecord
  629.         EXECUTE RecordStatus
  630.           BEGIN
  631.             LocalResponse = RequestCancelled
  632.             BREAK
  633.           END
  634.           CYCLE
  635.         END
  636.         BREAK
  637.       END
  638.       IF LocalResponse = RequestCancelled
  639.         POST(Event:CloseWindow)
  640.         CYCLE
  641.       END
  642.       OPEN(report)
  643.     OF Event:Timer
  644.       LOOP RecordsPerCycle TIMES
  645.         PRINT(RPT:detail)
  646.         LOOP
  647.           DO GetNextRecord
  648.           DO ValidateRecord
  649.           EXECUTE RecordStatus
  650.             BEGIN
  651.               LocalResponse = RequestCancelled
  652.               BREAK
  653.             END
  654.             CYCLE
  655.           END
  656.           BREAK
  657.         END
  658.         IF LocalResponse = RequestCancelled
  659.           LocalResponse = RequestCompleted
  660.           BREAK
  661.         END
  662.         LocalResponse = RequestCancelled
  663.       END
  664.       IF LocalResponse = RequestCompleted
  665.         POST(Event:CloseWindow)
  666.       END
  667.     END
  668.     CASE FIELD()
  669.     OF ?Progress:Cancel
  670.       CASE Event()
  671.       OF Event:Accepted
  672.         LocalResponse = RequestCancelled
  673.         POST(Event:CloseWindow)
  674.       END
  675.     END
  676.   END
  677.   contacts::Used -= 1
  678.   IF contacts::Used = 0 THEN CLOSE(contacts).
  679.   IF LocalResponse
  680.     GlobalResponse = LocalResponse
  681.   ELSE
  682.     GlobalResponse = RequestCancelled
  683.   END
  684.   RETURN
  685. !-----------------------------------------------------------------------------
  686. ValidateRecord       ROUTINE
  687.   RecordStatus = Record:OutOfRange
  688.   IF LocalResponse = RequestCancelled THEN EXIT.
  689.   IF ERRORCODE() THEN EXIT.
  690.   RecordStatus = Record:OK
  691.   EXIT
  692. GetNextcontacts ROUTINE
  693.   LocalResponse = RequestCancelled
  694.   LOOP
  695.     NEXT(contacts)
  696.     IF ERRORCODE() THEN EXIT.
  697.     RecordsProcessed += 1
  698.     RecordsThisCycle += 1
  699.     IF PercentProgress < 100
  700.       PercentProgress = (RecordsProcessed / RecordsToProcess)*100
  701.       IF PercentProgress > 100
  702.         PercentProgress = 100
  703.       END
  704.       ?Progress:Thermometer{Prop:Width} = ROUND(PercentProgress,0)
  705.       ?Progress:PctText{Prop:Text} = FORMAT(PercentProgress,@N5.1) & '% Completed'
  706.       DISPLAY()
  707.     END
  708.     BREAK
  709.   END
  710.   LocalResponse = RequestCompleted
  711.   EXIT
  712.  
  713. GetNextRecord ROUTINE
  714.   DO GetNextcontacts
  715.   IF LocalResponse = RequestCompleted THEN EXIT.
  716.